import { reactive,computed } from 'vue'
import { defineStore } from 'pinia'
import { iface_agreement,iface_ssq, iface_zd } from '@/types/global';

export const useAgreementStore = defineStore('agreement', () => {
	const agreement = reactive({
		xybh:'',
		type: '',
		jf: '',
		yf: '',
		startDate: new Date(),
		endDate: new Date(),
		areas: [{province:'1',city:'2',area:'3'}],
		zds: [],
		pp:[],
		areaTasks:[],
		zdTasks:[],
		activities:[],
		companies:[]
	} as iface_agreement)
	const getAgreementInfo = computed(() => {
		agreement.xybh = agreement.xybh.toLocaleUpperCase();
		return agreement;
	})
	function updateAgreementProperty(key : keyof iface_agreement, value : any) { agreement[key] = value; }
	function addArea (ssq:iface_ssq){
		agreement.areas.push(ssq);
	}
	function addZd (zd:iface_zd){
		agreement.zds.push(zd);
	}
	return { agreement,getAgreementInfo,updateAgreementProperty,addArea,addZd}
})